package com.clayecloud.lib_common.room.services;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.clayecloud.lib_common.room.entity.ClientToken;

import io.reactivex.Flowable;
import io.reactivex.Observable;
import io.reactivex.Single;

@Dao
public interface ClientTokenService {

    /**
     * 增加clientToken
     * @param clientToken
     * @return
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Single<Long> insertClientToken(ClientToken clientToken);

    /**
     * 删除clientToken
     * @param clientToken
     * @return
     */
    @Delete
    int deleteClientToken(ClientToken clientToken);


    /**
     * 更新clientToken
     * @param clientToken
     * @return
     */
    @Update
    int updateClientToken(ClientToken clientToken);


    /**
     * 根据id查询clientToken
     * @param userID
     * @return
     */
    @Query("select * from clientToken where user_id in (:userID)")
    Observable<ClientToken> getClientTokenById(int userID);

    /**
     * 根据id查询clientToken
     * @param userID
     * @return
     */
    @Query("select * from clientToken where user_id in (:userID)")
    Single<ClientToken> getClientTokenByIdWithSingle(int userID);


}
